----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 51312 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 1024
SPELL.m_sName = "Intercept"
SPELL.m_sToolTip = [[Dash directly to your 
					selected target.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/charge2.png"
SPELL.m_iCoolDown = 8
SPELL.m_iManaCost = 0
SPELL.m_bRequiresTarget = true
SPELL.m_iSpellType = SPELLTYPE_MOBILITY
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

function SPELL:Cast( pl, target )
	
	pl:EmitSound("devin/blackbetty/weapons/Charge.wav", 160, 100)
	local subtractedvectors = (pl:GetPos()) - target:GetPos()
	local subtractedvectorsnorm = (pl:GetPos()) - target:GetPos()
	subtractedvectorsnorm:Normalize()
	pl:DoAnimationEvent(ACT_HL2MP_RUN_FAST)
	pl:SetPos(pl:GetPos() + Vector(0, 0, 8))
	pl:SetAngles((target:GetPos() - pl:GetPos()):Angle())
	pl:SetVelocity(-(subtractedvectorsnorm*(2*subtractedvectors:Length()+378)))
	UpdatePlayerResource(pl, 25)
	target.Speed = true	
		target.SpeedMod = -1
		target.SpeedModDuration = 0.7
		target.SpeedType = "Charge"
	target:SetVelocity(target:GetVelocity()*-1) 
	timer.Simple(0.4, function()
		target.Speed = true 
		target.SpeedMod = 0.5
		target.SpeedModDuration = 5
		target.SpeedType = "Charge"
		pl:SetVelocity(pl:GetVelocity()*-1)
		pl:SetNWBool("Casting", false) 
		pl:SetNWBool("Casted", false)
	end)

end



